﻿package plugin.chatflash.component
{
    import __AS3__.vec.*;
    import com.core.*;
    import com.sh.game.consts.*;
    import com.sh.game.global.*;
    import com.sh.game.net.*;
    import com.sh.game.util.*;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.text.*;
    import flash.utils.*;
    import manager.*;
    import plugin.newteam.model.*;
    import plugin.roleN.model.*;
    import plugin.social.consts.*;
    import plugin.union.*;

    public class ChatMenu extends Sprite
    {
        private var mPanel:BitmapScale9Grid;
        private var mTFList:Vector.<TextField>;
        private var smallPanel:BitmapScale9Grid;
        private var small:Array;
        private var mData:Object;
        private var mFilter:DropShadowFilter;
        private var smallList:Vector.<TextField>;
        private var TITLE_LIST:Array;
        private var boxSmall:Sprite;

        public function ChatMenu()
        {
            this.small = ["30分钟", "1天", "永久"];
            this.mFilter = new DropShadowFilter(0, 0, 0, 0.8, 2, 2, 10, 1);
            this.TITLE_LIST = ["私    聊", "加为好友", "邀请组队", "查看装备", "邀请入会", "获得名字", "申请入队", "拉黑玩家", "禁言"];
            this.boxSmall = new Sprite();
            this.mTFList = new Vector.<TextField>;
            this.smallList = new Vector.<TextField>;
            this.createChildren();
            return;
        }// end function

        private function createChildren() : void
        {
            var _loc_3:TextField = null;
            var _loc_4:int = 0;
            this.mPanel = new BitmapScale9Grid(new Bitmap(App.asset.getBitmapData("png.common.s9_meue")), 7, 33, 8, 32);
            this.mPanel.width = 80;
            this.mPanel.height = 180;
            addChild(this.mPanel);
            this.smallPanel = new BitmapScale9Grid(new Bitmap(App.asset.getBitmapData("png.common.s9_meue")), 7, 33, 8, 32);
            this.smallPanel.width = 80;
            this.smallPanel.height = 70;
            this.boxSmall.addChild(this.smallPanel);
            this.addChild(this.boxSmall);
            this.boxSmall.x = 80;
            this.boxSmall.y = this.height - this.smallPanel.height;
            var _loc_1:int = 5;
            var _loc_2:* = ModelProxy.getValue("server", "onLogin")[4];
            if (_loc_2.isgm == 0)
            {
                this.TITLE_LIST = ["私    聊", "加为好友", "邀请组队", "查看装备", "邀请入会", "获得名字", "申请入队", "拉黑玩家"];
                this.mPanel.height = 160;
            }
            _loc_4 = 0;
            while (_loc_4 < this.TITLE_LIST.length)
            {
                
                _loc_3 = new TextField();
                _loc_3.autoSize = TextFieldAutoSize.CENTER;
                _loc_3.textColor = MColor.New15;
                _loc_3.filters = [this.mFilter];
                _loc_3.x = 10;
                _loc_3.y = _loc_1 + (14 + _loc_1) * _loc_4;
                _loc_3.width = 60;
                _loc_3.text = String(this.TITLE_LIST[_loc_4]);
                _loc_3.addEventListener(MouseEvent.CLICK, this.itemClickHandler, false, 0, true);
                _loc_3.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler, false, 0, true);
                _loc_3.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler, false, 0, true);
                addChild(_loc_3);
                this.mTFList.push(_loc_3);
                _loc_4++;
            }
            _loc_4 = 0;
            while (_loc_4 < this.small.length)
            {
                
                _loc_3 = new TextField();
                _loc_3.autoSize = TextFieldAutoSize.CENTER;
                _loc_3.textColor = MColor.New15;
                _loc_3.filters = [this.mFilter];
                _loc_3.x = 10;
                _loc_3.y = _loc_1 + (14 + _loc_1) * _loc_4;
                _loc_3.width = 60;
                _loc_3.text = String(this.small[_loc_4]);
                _loc_3.addEventListener(MouseEvent.CLICK, this.item2ClickHandler, false, 0, true);
                _loc_3.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler, false, 0, true);
                _loc_3.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler, false, 0, true);
                this.boxSmall.addChild(_loc_3);
                this.smallList.push(_loc_3);
                _loc_4++;
            }
            this.boxSmall.visible = false;
            return;
        }// end function

        protected function item2ClickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = this.smallList.indexOf(TextField(event.currentTarget));
            var _loc_3:* = int((ModelProxy.getValue("data", "servertime") + Number(getTimer())) / 1000);
            switch(_loc_2)
            {
                case 0:
                {
                    Server.instance.send(99, 0, "@禁言 " + this.data.name + " " + 1800, 0, ConnectType.SYSTEM);
                    break;
                }
                case 1:
                {
                    Server.instance.send(99, 0, "@禁言 " + this.data.name + " " + 98640, 0, ConnectType.SYSTEM);
                    break;
                }
                case 2:
                {
                    Server.instance.send(99, 0, "@禁言 " + this.data.name + " " + 500000000, 0, ConnectType.SYSTEM);
                    break;
                }
                default:
                {
                    break;
                }
            }
            this.hide();
            return;
        }// end function

        private function itemClickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = this.mTFList.indexOf(TextField(event.currentTarget));
            switch(_loc_2)
            {
                case 0:
                {
                    ModelProxy.change("chat", "pritalk", this.data);
                    break;
                }
                case 1:
                {
                    PluginManager.instance.sendToServer("social", CMDSocial.APPLYFOR, this.data.rid);
                    break;
                }
                case 2:
                {
                    PluginManager.instance.sendToServer("team", CMDteam.TEAM_INVITE, this.data.rid);
                    break;
                }
                case 3:
                {
                    PluginManager.instance.sendToServer("role", CMDRole.LookOther, this.data.rid);
                    break;
                }
                case 4:
                {
                    UnionSender._19unionInvite(this.data.rid);
                    break;
                }
                case 5:
                {
                    ModelProxy.change("chat", "addName", this.data.name);
                    break;
                }
                case 6:
                {
                    PluginManager.instance.sendToServer("team", CMDteam.TEAM_APPLY, this.data.rid);
                    break;
                }
                case 7:
                {
                    PluginManager.instance.sendToServer("social", CMDSocial.AddHei, this.data.rid);
                    break;
                }
                case 8:
                {
                    this.boxSmall.visible = true;
                    return;
                }
                default:
                {
                    break;
                }
            }
            this.hide();
            return;
        }// end function

        private function rollOverHandler(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget as TextField;
            _loc_2.textColor = MColor.New16;
            return;
        }// end function

        private function rollOutHandler(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget as TextField;
            _loc_2.textColor = MColor.New15;
            return;
        }// end function

        private function stageClickHandler(event:MouseEvent) : void
        {
            if (this.visible && !this.hitTestPoint(GlobalLayer.instance.root.mouseX, GlobalLayer.instance.root.mouseY))
            {
                this.hide();
            }
            return;
        }// end function

        public function show(param1:Number, param2:Number, param3:Object = null) : void
        {
            this.x = param1;
            if (GlobalLayer.instance.root.stageHeight - param2 < this.mPanel.height)
            {
                this.y = GlobalLayer.instance.root.stageHeight - this.mPanel.height;
            }
            else
            {
                this.y = param2;
            }
            this.visible = true;
            if (param3)
            {
                this.mData = param3;
            }
            GlobalLayer.instance.root.addEventListener(MouseEvent.CLICK, this.stageClickHandler, false, 0, true);
            return;
        }// end function

        public function hide() : void
        {
            this.visible = false;
            this.boxSmall.visible = false;
            GlobalLayer.instance.root.removeEventListener(MouseEvent.CLICK, this.stageClickHandler);
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this.mData = param1;
            return;
        }// end function

        public function get data() : Object
        {
            return this.mData;
        }// end function

    }
}
